#include "vertex_array.h"


namespace teflon
{
	VertexArray::VertexArray()
	{
		glGenVertexArrays(1, &vao);
	}

	VertexArray::~VertexArray()
	{
		glDeleteVertexArrays(1, &vao);
#if 0
		for (auto vbo : vbos)
		{
			glDeleteBuffers(1, &vbo);
		}
#else
		glDeleteBuffers(int(vbos.size()), vbos.data());
#endif
	}

	void VertexArray::AddData(GLfloat* data, int num_vertices, int vertex_size, int location)
	{
		GLuint vbo;
		glGenBuffers(1, &vbo);
		glBindBuffer(GL_ARRAY_BUFFER, vbo);
		glBufferData(GL_ARRAY_BUFFER, num_vertices * vertex_size * sizeof(GLfloat), data, GL_STATIC_DRAW);
		glVertexAttribPointer(location, vertex_size, GL_FLOAT, GL_FALSE, 0, NULL);
		glEnableVertexAttribArray(location);
		vbos.push_back(vbo);
	}

	void VertexArray::Clear()
	{
		// 
	}
}
